//
//  MainViewController.m
//  第六组电影项目
//
//  Created by 6-1 on 14-7-3.
//  Copyright (c) 2014年 www.skedu.com.cn北京尚德智远科技有限公司. All rights reserved.
//

#import "MainViewController.h"
#import "USAViewController.h"
#import "NewsViewController.h"
#import "TopViewController.h"
#import "CinemaViewController.h"
#import "MoreViewController.h"
#import "BaseNavigationController.h"
#import "TabBarButton.h"

@interface MainViewController ()

-(void)loadViewControllers;
-(void)customTabBarView;

@end

@implementation MainViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self loadViewControllers];
    [self settingTabBar];
	// Do any additional setup after loading the view.
}

-(void)loadViewControllers{
    //北美票房
    USAViewController *usaVC=[[USAViewController alloc]init];
    //新闻
    NewsViewController *newsVC=[[NewsViewController alloc]init];
    //排行榜
    TopViewController *topVC=[[TopViewController alloc]init];
    //影院
    CinemaViewController *cinemaVC=[[CinemaViewController alloc]init];
    //更多
    //MoreViewController *moreVC=[[MoreViewController alloc]init];
    
    NSArray *array1 = @[usaVC,newsVC,topVC,cinemaVC];
    NSMutableArray *mutableArray = [NSMutableArray array];
    NSArray *normalImage=@[@"movie_home",@"msg_new",@"start_top250",@"icon_cinema"];
    NSArray *titlesArray=@[@"电影",@"新闻",@"排行榜",@"影院"];
    for (int i=0; i<array1.count; i++)
    {
        UIViewController *viewController = array1[i];
        viewController.tabBarItem = [[UITabBarItem alloc]initWithTitle:titlesArray[i] image:[[UIImage imageNamed:normalImage[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:titlesArray[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        BaseNavigationController *navController = [[BaseNavigationController alloc]initWithRootViewController:viewController];
        [mutableArray addObject:navController];
    }
    [self setViewControllers:mutableArray animated:YES];
}

//设置底部分栏属性
-(void)settingTabBar
{
    self.tabBar.translucent = NO;

    [self.tabBar setBackgroundImage:[UIImage imageNamed:@"tab_bg_all"]];
    //设置分栏字体色(普通状态)
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor darkGrayColor],NSForegroundColorAttributeName,[UIFont boldSystemFontOfSize:11],NSFontAttributeName,[UIColor clearColor],NSBackgroundColorAttributeName,nil] forState:UIControlStateNormal];
    //设置分栏字体色(选中状态)
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,[UIFont boldSystemFontOfSize:11],NSFontAttributeName,[UIColor clearColor],NSBackgroundColorAttributeName,nil] forState:UIControlStateSelected];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
